{% extends 'base.html' %}

{% block content %}
<body>
  <form class="layui-form">
  <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
    <legend>WebHook（钉钉&飞书）</legend>
  </fieldset>
  
  <div class="layui-form-item">
    <div class="layui-input-inline" style="margin-left: 2%;width: 800px;">
        <input type="text" id="dd_hook" name="dd_hook"  required="" autocomplete="off" class="layui-input" placeholder="egg：https://xxx.xxx" width="800px" lay-verify="dd_hook" value="{{hook}}">
        <button class="layui-btn layui-btn-normal" lay-filter="hook" lay-submit="" style="margin-top: -7%;margin-left: 101%;">保存设置</button>
    </div>
</div>

<div class="layui-form-item">
  
</div>

</form>


<script>
  layui.use(['form', 'layer'],
  function() {
      $ = layui.jquery;
      var form = layui.form,
      layer = layui.layer;

      //自定义验证规则
      form.verify({
        dd_hook: [/\S/, 'Hook不能为空'],
      });

      //监听提交
      form.on('submit()',
      function(data) {
          //console.log(data);
          $.post(data.form.action,data.field);
          //发异步
          layer.alert("设置成功", {
              icon: 6
          },
          function() {
              // 获得frame索引
              var index = parent.layer.getFrameIndex(window.name);
              
              //关闭当前frame
              parent.layer.close(index);
              
              // 可以对父窗口进行刷新
              xadmin.father_reload();
          });
          return false;
      });

  });
</script>
   
</body>
{% endblock %}